#include "flabel.h"

FLabel::FLabel(QWidget *parent)
    : QWidget(parent)
{
    QFont fFont;
    fFont.setPointSize(14);

    ml1 = new QLabel(this);
    ml1->setFixedSize(400,400);

    ge1 = new QGraphicsOpacityEffect ;
    ge1->setEnabled(true);
    ge1->setProperty("opacity",0);
    ml1->setGraphicsEffect(ge1);

    mAni_opacity1 = new QPropertyAnimation;
    iniAnimationOp(mAni_opacity1,ge1,QEasingCurve::OutExpo,"opacity",1000,0.3,1);

    ml2 = new QLabel(this);
    ml2->setFixedSize(400,400);
    ml2->setStyleSheet("color:white;");
    ml2->setAlignment(Qt::AlignTop);
    ml2->setFont(fFont);
//    ml2->setText("TEST\nTEST");

    ge2 = new QGraphicsOpacityEffect ;
    ge2->setEnabled(true);
    ge2->setProperty("opacity",0);
    ml2->setGraphicsEffect(ge2);

    mAni_opacity2 = new QPropertyAnimation;
    iniAnimationOp(mAni_opacity2,ge2,QEasingCurve::OutExpo,"opacity",1000,0.8,1);

    aniGrp = new QSequentialAnimationGroup;
    aniGrp->addAnimation(mAni_opacity1);
    aniGrp->addAnimation(mAni_opacity2);

}

void FLabel::iniAnimationOp(QPropertyAnimation *ani,QGraphicsOpacityEffect  *gre,QEasingCurve curve,QString f_pro,int f_duration,double f_stVal,double f_edVal)
{
    ani->setTargetObject(gre);
    QByteArray pn = f_pro.toUtf8();
    ani->setPropertyName(pn);
    ani->setEasingCurve(curve);
    ani->setLoopCount(1);
    ani->setDuration(f_duration);
    ani->setStartValue(f_stVal);
    ani->setEndValue(f_edVal);
}

void FLabel::setPic(QPixmap *fimg)
{
    ml1->setPixmap(*fimg);
    ml1->setScaledContents(true);
}

void FLabel::setInfo(QString date,QString picFileName,QString x,QString y,QString z)
{
    ml2->setText(QString("日期：%1\n文件:   %2\n经度：%3\n纬度：%4\n海拔：%5").arg(date,picFileName,x,y,z));
}

void FLabel::setInfo(QString dmaaName)
{
    ml2->setText(QString("名称：%1").arg(dmaaName));
    ml2->setFixedSize(400,50);
    ml2->setAlignment(Qt::AlignVCenter);
    ml1->setScaledContents(false);
    ml1->setFixedSize(400,50);
}
